﻿using System.Security.Cryptography;
using System.Text;

namespace FileZillaConfig.Helpers
{
    static class  MD5Hash
    {
        public static string CalculateMD5Hash(string input)
        {
            if (input != null)
            {
                MD5 md5 = System.Security.Cryptography.MD5.Create();
                byte[] bytes = System.Text.Encoding.ASCII.GetBytes(input);
                byte[] hash = md5.ComputeHash(bytes);

                StringBuilder sBuilder = new StringBuilder();
                for (int i = 0; i < hash.Length; i++)
                {
                    sBuilder.Append(hash[i].ToString("x2"));
                }
                return sBuilder.ToString();
            }
            return "";
        }    
    }
}
